home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / BBMAINT2.CMD < prev    next >
OS/2 REXX Batch file  |  1992-03-24  |  24KB  |  907 lines

  1. ;****    TRACE ON        ; Debugging
  2. ;
  3. ; ----- COM-AND BBS file maintenance script (Files file)
  4. ;    Commenced: 11/90 R.McG
  5. ; -----------------------------------------------------------------------
  6. ;    Purpose:
  7. ;       The script, named BBMAINT2.CMD, produces the main window for
  8. ;    Filedir functions of BBMAINT, and implements its functions.  It
  9. ;    is not directly callable itself.
  10. ; -----------------------------------------------------------------------
  11. ;    Usage:
  12. ;       N99 -> Text attribute value (Setup by BBMAINT.CMD)
  13. ;       N98 -> BBMAINT Mainline cursor position
  14. ;       N97 -> BBMAINT Mainline cursor position
  15. ;       N96 -> our mainline cursor position
  16. ;       N95 -> our mainline cursor position
  17. ; -----------------------------------------------------------------------
  18. ;
  19. ;    This script is intended ONLY to be used for FCALL
  20. ;
  21.     IF NOT FCALLED
  22.        WOPEN 10,10,13,70 (cont) NOFIEsc
  23.        ATSAY 10,12 (cont) " BBS Files "
  24.        ATSAY 11,12 (cont) " The script: "*"_SCRIPT"
  25.        ATSAY 12,12 (cont) " is not used by itself... it is called through BBMAINT"
  26.        ATSAY 13,26 (cont) " Press any key to continue "
  27.        ;
  28.        ;    Wait a keypress
  29.        ;
  30.        KEYGET S0        ; Wait for any key
  31.        WCLOSE        ; Close open window
  32.        EXIT         ; Terminate right here
  33.        ENDIF
  34.     GOSUB FileFile        ; Invoke function
  35.     FRETURN         ; Return to caller
  36. ; -----------------------------------------------------------------------
  37. ; ----- NoFile:  Inform that there's no BBS-FIle file to modify
  38. ;
  39. NoFile:
  40.     WOPEN 10,10,13,70 (cont) NOFIEsc
  41.     ATSAY 10,12 (cont) " BBS FileDir "
  42.     ATSAY 11,12 (cont) " The file: "*S23&"\BBS-File"
  43.     ATSAY 12,12 (cont) " does not exist.  Please create subdirectories first."
  44.     ATSAY 13,26 (cont) " Press any key to continue "
  45.     ;
  46.     ;    Wait a keypress
  47.     ;
  48.     KEYGET S0        ; Wait for any key
  49.     WCLOSE
  50. NOFIEsc:
  51.     RETURN
  52. ; -----------------------------------------------------------------------
  53. ; ----- Subroutine: FileFile -> Update FILE directory
  54. ;
  55. FileFile:
  56.     GOSUB NewFile        ; Create if not there
  57.     IF NOT ISFILE S23&"\BBS-FIle"
  58.        GOSUB NoFile     ; Inform there's no file
  59.        RETURN        ; .. so we can't continue
  60.        ENDIF
  61. ;
  62. ;    Open a window
  63. ;
  64.     WOPEN 0,0 23,79 (defa) File_Esc
  65.     ATSAY 0,2 (defa)   " BBS Files "
  66.     ATSAY 23,25 (defa) " Press ESC to cancel BBMAINT "
  67. ;
  68. ;    Paint the window
  69. ;
  70. FIFI100:
  71.     CLEAR            ; Clear window
  72.     LOCATE 2,2
  73.  
  74.     MESS " 1) Add a file to the up/download list"
  75.     MESS " 2) Delete a file from the list"
  76.     MESS " 3) Modify a file's listing"
  77.     MESS " 4) Print the file list"
  78.     MESS " 5) View the file list"
  79.     MESS "──────────────────────────────────── "
  80.     MESS "Note: Alt-Q to edit a file"
  81.     MESS "      Alt-F for a directory search"
  82.     MESS "      Alt-F10 to shell to DOS"
  83.     MESS " "
  84.     MESS "──────────────────────────────────── "
  85.     MESS " "
  86.     MESS "Select item (carriage return = previous): "
  87.     CURSOR N96,N95        ; Read current cursor
  88. ;
  89. ;    Wait for entry, and interpret
  90. ;
  91. FIFI200:
  92.     LOCATE N96 N95        ; Reposition cursor
  93.     KEYGET S0        ; Wait for it
  94.     SWITCH S0        ; Act according to keyget
  95.       CASE "1"
  96.            GOSUB AddFile
  97.            ENDCASE
  98.       CASE "2"
  99.            GOSUB DelFile
  100.            ENDCASE
  101.       CASE "3"
  102.            GOSUB ModFile
  103.            ENDCASE
  104.       CASE "4"
  105.            GOSUB PrnFile
  106.            ENDCASE
  107.       CASE "5"
  108.            GOSUB ViewFile
  109.            GOTO FIFI100    ; Repaint after this
  110.            ENDCASE
  111.       CASE "0d"             ; c/r alone is exit
  112.            WCLOSE        ; Close window...
  113.            RETURN        ; and return to caller
  114.            ENDCASE
  115.       CASE "_NULL"          ; ESC -> Null
  116.            WCLOSE        ; Close window...
  117.            RETURN        ; Leave Main routine
  118.            ENDCASE
  119.       CASE "2100"           ; Alt-F
  120.            MANUAL "0x2100"  ; Perform Dir cmd
  121.            ENDCASE
  122.       CASE "1000"           ; Alt-Q
  123.            MANUAL "0x1000"  ; Edit a file
  124.            ENDCASE
  125.       CASE "7100"           ; Alt-F10
  126.            SHELL
  127.            DWINDOW 1,2,22,78; Reset dwindow after shell
  128.            LEGEND "_LEGEND" ; Redo the legend
  129.            ENDCASE
  130.       DEFAULT        ; None of the above
  131.            SOUND 100,100    ; Bronx cheer
  132.            ENDCASE
  133.       ENDSWITCH
  134.     GOTO FIFI200        ; Repaint screen and ask again
  135. ;
  136. ;    End of Files procedure
  137. ;
  138. File_Esc:
  139.     S0 = ""                 ; Fake null entry
  140.     RETURN            ; Leave files routine
  141. ; -----------------------------------------------------------------------
  142. ; ----- AddFile:  Add a file to the File directory
  143. ;
  144. AddFile:
  145.     SET FLAG(0) OFF     ; Flag for ESCAPE
  146.     WOPEN 10,10,16,75 (cont) ADFIEsc
  147.     ATSAY 10,12 (cont) " BBS Files Add "
  148.     ATSAY 11,12 (cont) "Enter the file to be added: "
  149.     ATSAY 16,26 (cont) " Press ESC to cancel "
  150.     ;
  151.     ;    Wait a keypress
  152.     ;
  153.     LOCATE 11,42
  154.     GET S0 12        ; get fname
  155.     IF FLAG(0) GOTO ADFIEnd ; Exit if ESC hit
  156.     LJ S0            ; Left justify - don't upper case
  157.     IF NULL S0 GOTO ADFIEnd ; get out on empty entry
  158.     GOSUB LkpFile        ; Lookup name in files file
  159.     IF FOUND        ; If its there we can't add it
  160.        WCLOSE        ; Close open window
  161.        GOTO ModFI_Add    ; Skip if file found
  162.        ENDIF
  163.     S10 = S0        ; Save File name
  164.     GOTO ADFI100        ; And branch around parallel code
  165. ;
  166. ;    Entry from ModFile... Nothing to modify
  167. ;
  168. AddFI_Mod:
  169.     WOPEN 10,10,16,75 (cont) ADFIEsc
  170.     ATSAY 10,12 (cont) " BBS Files Add "
  171.     ATSAY 11,12 (cont) "Enter the file to be added: "
  172.     ATSAY 11,42 (cont) S0
  173.     ATSAY 16,26 (cont) " Press ESC to cancel "
  174.     S10 = S0        ; Copy it for remainder
  175. ;
  176. ;    Look for the file - Add date and size to listing
  177. ;
  178. ADFI100:
  179.     FDATE S1 S23&"\"&S0     ; Ask for the file date (bbs-file subdir)
  180.     IF FAILED GOTO ADFI110    ; Skip if d.n.e
  181.     S10(12:19) = S1     ; Place date of file
  182.     FSIZE S1 S23&"\"&S0     ; Ask for the file size (bbs-file subdir)
  183.     IF FAILED GOTO ADFI110    ; Skip if d.n.e
  184.     S10(21:27) = S1     ; Place size of file (7 digits)
  185.     ATSAY 12,12 (cont) "File date and size:"
  186.     ATSAY 12,42 (cont) S10(12:27)
  187.     GOTO ADFI200        ; SKip around error handler
  188. ;
  189. ;    File does not exist...
  190. ;
  191. ADFI110:
  192.     ATSAY 12,12 (cont) "File d.n.e. Add anyway (y/n): "
  193.     LOCATE 12,42
  194.     GET S0 1        ; get resp
  195.     IF FLAG(0) GOTO ADFIEnd ; Exit if ESC hit
  196.     IF NULL S0 or NOT FIND "YN" S0(0)
  197.        SOUND 100,100    ; Indicate displeasure
  198.        GOTO ADFI110     ; Try again
  199.        ENDIF
  200.     IF FIND "N" S0(0)
  201.        WCLOSE        ; Close window
  202.        GOTO AddFile     ; And try again
  203.        ENDIF
  204.     S10(12:27) = "******** ********"
  205. ;
  206. ;    Ask for a comment field
  207. ;
  208. ADFI200:
  209.     ATSAY 13,12 (cont) "Comment text: "
  210.     LOCATE 13,26
  211.     GET S0 40        ; get resp
  212.     LJ S0            ; Left justify
  213.     IF FLAG(0) GOTO ADFIEnd ; Exit if ESC hit
  214.     IF NULL S0
  215.        SOUND 100,100    ; Indicate displeasure
  216.        GOTO ADFI200     ; Try again
  217.        ENDIF
  218.     S10(28:79) = S0     ; Save comment text
  219. ;
  220. ;    Ask for privileged flag
  221. ;
  222. ADFI250:
  223.     ATSAY 14,12 (cont) "Priveleged access (y/n):  "
  224.     LOCATE 14,42
  225.     GET S0 1        ; get resp
  226.     IF FLAG(0) GOTO ADFIEnd ; Exit if ESC hit
  227.     IF NULL S0 or NOT FIND "YN" S0(0)
  228.        SOUND 100,100    ; Indicate displeasure
  229.        GOTO ADFI250     ; Try again
  230.        ENDIF
  231.     IF FIND "Y" S0(0) S10(20:20) = "P" ; Save priveleged access
  232. ;
  233. ;    Ask for one more look
  234. ;
  235. ADFI300:
  236.     ATSAY 15,12 (cont) "OK to add this record?:   "
  237.     LOCATE 15,42
  238.     GET S0 1        ; get resp
  239.     IF FLAG(0) GOTO ADFIEnd ; Exit if ESC hit
  240.     IF NULL S0 or NOT FIND "YN" S0(0)
  241.        SOUND 100,100    ; Indicate displeasure
  242.        GOTO ADFI300     ; Try again
  243.        ENDIF
  244.     IF FIND "N" S0(0)
  245.        WCLOSE        ; Close window
  246.        GOTO AddFile     ; And try again
  247.        ENDIF
  248. ;
  249. ;    Write the record
  250. ;
  251.     GOSUB AddFRec        ; Write to Files file
  252. ;
  253. ;    End of add procedure
  254. ;
  255. ADFIEnd:
  256.     WCLOSE
  257. ADFIEsc:
  258.     SET FLAG(0) ON
  259.     RETURN
  260. ; -----------------------------------------------------------------------
  261. ; ----- AddFRec:  Add a record to the file file...
  262. ;    .. S10 passes the record to be written
  263. ;
  264. AddFRec:
  265.     FOPENO S23&"\BBS-File" TEXT APPEND
  266.     IF NOT SUCCESS        ; Open failed
  267.        S0 = "Error opening: "*S23&"\BBS-File"
  268.        GOSUB Error        ; Report
  269.        RETURN        ; And we're done
  270.        ENDIF
  271.     PRESERVE S10        ; Preserve ^'s and !'s
  272.     WRITE S10        ; Write the record
  273.     WRITE "!^Z"             ; And finish it
  274.     FCLOSEO
  275.     RETURN
  276. ; -----------------------------------------------------------------------
  277. ; ----- LkpFile:  Lookup a file in the BBS-File file
  278. ;    .. S0 passes the fname to be tested
  279. ;    .. S10 returns the record read
  280. ;
  281. LkpFIle:
  282.     FOPENI S23&"\BBS-File" T